#include <iostream>
#include <vector>
using namespace std;
vector<int> arr;
vector<int> memo;
int n, A, B;
int min_steps = 1e9;
void dfs(int floor, int steps)
{
    if (steps >= min_steps)
    {
        return;
    }
    if (memo[floor] != -1 && memo[floor] <= steps)
    {
        return;
    }

    memo[floor] = steps;

    if (floor == B)
    {
        min_steps = min(steps, min_steps);
        return;
    }
    // 上
    int up_floor = floor + arr[floor];
    if (up_floor <= n)
        dfs(up_floor, steps + 1);
    // 下
    int down_floor = floor - arr[floor];
    if (down_floor >= 1)
        dfs(down_floor, steps + 1);
}
int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> A >> B;
    arr.resize(n + 1);
    memo.resize(n + 1, -1);
    for (int i = 1; i <= n; i++)
    {
        cin >> arr[i];
    }
    dfs(A, 0);
    if (min_steps == 1e9)
        cout << "-1" << endl;
    else
        cout << min_steps << endl;
    return 0;
}